<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 字符串  </title>
</head>
<body>
    
</body>
<script>


// startsWith  endsWith includes字符串是否包含
    let mobile1 = '15735212860';
    let mobile2 = '15234500298';

    console.log(mobile1,mobile1.startsWith('152'));
    console.log(mobile2 ,mobile2.startsWith('152'));

    console.log(mobile1,mobile1.endsWith('2860'));
    console.log(mobile2,mobile2.endsWith('2860'));

    console.log(mobile1,mobile1.includes('521'));
    console.log(mobile2,mobile2.includes('521'));
    
//indexOf() 方法返回调用它的 String 对象中第一次出现的指定值的索引，从 fromIndex 处进行搜索。如果未找到该值，则返回 -1。

    let url = "http://www.baidu.com/logo.jpg";
    let name = 'zhangsan';
    let index = url.lastIndexOf('/');
    let fileName= url.substring(index + 1);
    console.log(fileName);
    

    console.log(name.indexOf('g'));
    console.log(name.lastIndexOf('a'));
    
 //padStart() 方法用另一个字符串填充当前字符串(重复，如果需要的话)
 
     let s1 = '1';
     let s2 = '2.4';
     console.log(s1.padStart(5,'0'));
     console.log(s2.padEnd(5,'0'));

//substring() 用于截取字符串，他会返回一个新的字符串，而不会修改原始的字符串，经常会搭配indexOf  lastIndexOf 使用

     let s3 = 'abcdefg';
     let s4 = s3.substring(0,3);
     console.log(s4);
     
 //  trim ()方法可以去除字符串首尾两端的空格，中间的空格不会处理
   
    let s5 ='                     aaa     6      ';
    console.log(s5);
    console.log(s5.trim());
    //console.log(s5.replaceAll(' ','#'));

//  大小写互换

    let s6 = "ABCDEFG";
    //console.log(s6.toUpperCase());
    console.log(s6.toLowerCase());

    let names = '张三,李四,王五,麻子';
    let nameList = names.split(',');
    console.log(nameList);
    



</script>

</html>